﻿// Decompiled with JetBrains decompiler
// Type: DnProcessSimulateCommands.ViewCamera.Rgbd.CApRgbdConfigCmd
// Assembly: DnProcessSimulateCommands, Version=2402.0.0.890, Culture=neutral, PublicKeyToken=null
// MVID: A885D881-AEDF-447E-852A-6F13102E089C
// Assembly location: C:\Program Files\Tecnomatix_2402\eMPower\DotNetCommands\DnProcessSimulateCommands.dll

using EngineeringInternalExtension;
using System.Windows;
using Tecnomatix.Engineering;
using Tecnomatix.Engineering.Ui;


namespace DnProcessSimulateCommands.ViewCamera.Rgbd;

public sealed class CApRgbdConfigCmd : TxButtonCommand
{
  private ITxCommandEnabler _enabler;

  public CApRgbdConfigCmd() => this._enabler = (ITxCommandEnabler) new CApRgbdConfigCmdEnabler();

  public virtual string Category => RgbdResources.CMD_CATEGORY;

  public virtual string Name => RgbdResources.CMD_NAME;

  public virtual ITxCommandEnabler CommandEnabler => this._enabler;

  public virtual ITxImage Image => (ITxImage) TxImageManager.GetImageByKey("CameraSettings");

  public virtual void Execute(object cmdParams)
  {
    TxViewCamera selectedViewCamera = TxRgbdUtils.GetSelectedViewCamera();
    TxGraphicViewer txGraphicViewer = (TxGraphicViewer) null;
    foreach (TxGraphicViewer graphicViewer in TxApplication.ViewersManager.GraphicViewers)
    {
      TxViewCamera coupledCamera = graphicViewer.GetCoupledCamera();
      if (TxViewCamera.op_Inequality(coupledCamera, (ITxObject) null) && coupledCamera.Equals((object) selectedViewCamera))
      {
        txGraphicViewer = graphicViewer;
        TxViewersManagerEx.SetActiveViewer((TxViewerControl) txGraphicViewer);
        TxApplication.ViewersManager.BringGraphicViewerToFront((TxViewerControl) txGraphicViewer);
        break;
      }
    }
    if (txGraphicViewer == null)
    {
      txGraphicViewer = TxRgbdUtils.OpenNewGraphicViewer();
      selectedViewCamera.CoupleToGraphicViewer(txGraphicViewer);
    }
    TxRgbdDepthBinaryReaderWriter readerWriter = new TxRgbdDepthBinaryReaderWriter();
    ((Window) new CUiRgbdConfigWindow(new TxRgbdViewCamera(selectedViewCamera, txGraphicViewer), (ITxRgbdDepthReaderWriter) readerWriter)).Show();
  }
}
